<?php

namespace app\admin\validate\setting;

use tmcore\base\BaseValidate;

/**
 * 短信配置验证器
 */
class PayValidate extends BaseValidate
{

    protected $rule = [
        'icon' => 'require',
        'status' => 'require',
        'identify' => 'require|checkIdentify',
    ];

    protected $message = [
        'icon.require' => '图标不能为空',
        'status.require' => '状态不能为空',
        'identify.require' => '支付标识参数不能为空',
    ];

    /**
     * 设置支付参数场景
     * @return PayValidate
     */
    public function sceneEdit()
    {
        return $this->only(['identify','status','icon']);
    }


    /**
     * 获取配置参数信息场景
     * @return PayValidate
     */
    public function sceneDetail()
    {
        return $this->only(['identify']);
    }

    /**
     * 检查支付标识
     * @param $value
     * @return bool|string
     */
    public function checkIdentify($value)
    {
        if(!in_array($value, ['cash','balance','wechat','alipay'])) return '支付标识参数错误';
        return true;
    }
}